import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:megatron/main/mainpage.dart';
import 'package:megatron/main/videoplay.dart';
import 'login/login.dart';
import 'main.dart';
import 'setting/setting.dart';

class Routes {
  static FluroRouter router;
  static String rootPage = '/';
  static String login = '/login/login';
  static String mainpage = '/mainpage/mainpage';
  static String setting = '/setting/setting';
  static String videoplay = 'videoplay';

  static var loginHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Login();
  });
  static var mainPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MainPage();
  });
  static var settingPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Setting();
  });
  static var svideoplayHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String id = params['id']?.first;
    String size = params['size']?.first;
    String length = params['length']?.first;
    String creatorDeptName = params['creatorDeptName']?.first;
    String creatorName = params['creatorName']?.first;
    String createDate = params['createDate']?.first;

    return VideoPlay(id: id, size: size, length: length,creatorDeptName:creatorDeptName,creatorName:creatorName,createDate:createDate);
  });

  static void configureRoutes(FluroRouter router) {
    router.define(rootPage,
        handler: Handler(handlerFunc: (context, params) => PageRoot()));

    router.define(login, handler: loginHandler);
    router.define(mainpage, handler: mainPageHandler);
    router.define(setting, handler: settingPageHandler);
    router.define(videoplay, handler: svideoplayHandler);
    Routes.router = router;
  }
}
